package com.koron.system.configSettings.post.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.koron.bean.query.PageQuery;
import com.koron.bean.system.post.po.PostUserPo;
import com.koron.bean.system.post.query.PostUserFilterQuery;
import com.koron.bean.system.post.query.PostUserQuery;
import com.koron.bean.system.post.vo.PostUserVo;
import com.koron.system.configSettings.post.mapper.PostUserMapper;
import com.koron.system.configSettings.post.service.PostUserService;
import org.apache.commons.collections4.CollectionUtils;
import org.koron.ebs.mybatis.TaskAnnotation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * (PostUser)表服务实现类
 *
 * @author zhouj
 * @since 2022-01-10 10:13:33
 */
@Service("postUserService")
public class PostUserServiceImpl implements PostUserService {

    @Autowired
    PostUserMapper mapper;

    @Override
    @TaskAnnotation("insertOrUpdate")
    public int insertOrUpdate(PostUserPo postUser) {

        return mapper.insertOrUpdate(postUser);
    }

    @Override
    @TaskAnnotation("insertOrUpdateBatch")
    public int insertOrUpdateBatch(List<PostUserPo> postUserList) {

        return mapper.insertOrUpdateBatch(postUserList);
    }

    @Override
    @TaskAnnotation("insert")
    public int insert(PostUserPo postUser) {

        return mapper.insert(postUser);
    }

    @Override
    @TaskAnnotation("insertBatch")
    public int insertBatch(List<PostUserPo> postUserList) {

        return mapper.insertBatch(postUserList);
    }

    @Override
    @TaskAnnotation("update")
    public int update(PostUserPo postUser) {
        return mapper.update(postUser);
    }

    @Override
    @TaskAnnotation("deleteById")
    public int deleteById(String id) {

        return mapper.deleteById(id);
    }

    @Override
    @TaskAnnotation("queryById")
    public PostUserPo queryById(String id) {

        return mapper.queryById(id);
    }

    @Override
    @TaskAnnotation("queryList")
    public List<PostUserVo> queryList(PostUserQuery postUserQuery) {

        List<PostUserVo> list = mapper.queryVoList(postUserQuery);

        return list;
    }

    @Override
    @TaskAnnotation("filterUser")
    public List<PostUserVo> filterUser(List<PostUserFilterQuery> filterQueryList) {

        if (CollectionUtils.isEmpty(filterQueryList)) {
            return new ArrayList<>();
        }
        List<PostUserVo> list = mapper.filterUser(filterQueryList);

        return list;
    }

    @Override
    @TaskAnnotation("queryPageList")
    public PageInfo queryPageList(PostUserQuery postUserQuery, PageQuery pageQuery) {

        PageHelper.startPage(pageQuery.getPage(), pageQuery.getPageSize(), pageQuery.getOrderBy());

        List<PostUserVo> list = mapper.queryVoList(postUserQuery);

        return new PageInfo(list);
    }

}
